require(['../config'], () => {
    require(['template', 'header', 'footer'], (template) => {
        class lists {
            constructor() {
                    this.num = 12
                    this.getlist()
                    this.getMore()
                }
                // http://xiongmaoyouxuan.com/api/search?word=%E6%B0%B4%E6%9E%9C+&start=0&sort=0&couponOnly=0&minPrice=0&maxPrice=99999
                // http://xiongmaoyouxuan.com/api/search?word=%E6%B0%B4%E6%9E%9C&start=40&sort=0&couponOnly=0&minPrice=0&maxPrice=99999
            getlist() {

                const url = "http://xiongmaoyouxuan.com/api/search?word=%E6%B0%B4%E6%9E%9C&start=" + this.num + "&sort=0&couponOnly=0&minPrice=0&maxPrice=99999"
                $.get(url, {
                    // word: '%E6%B0%B4%E6%9E%9C+',
                    // start: 0,
                    // sort: 0,
                    // couponOnly: 0,
                    // minPrice: 0,
                    // maxPrice: 99999
                }, resp => {
                    const html = template('listsTemplate', {
                        lists: resp.data.list.slice(this.num - 12, this.num)
                    })
                    console.log(this.num)
                    if (this.num <= 24) { $('.main-section').css("height", this.num * 498 / 4 + 50) } else {
                        $('.main-section').css("height", this.num * 568 / 4 + 50)
                    }

                    // console.log(resp.data.list)
                    $('#lists').html($('#lists').html() + html)
                })
            }
            getMore() {
                $('.listMore').on('click', () => {
                    this.num = this.num + 12
                    if (this.num >= 32) this.num = 32

                    // console.log(this.num)
                    this.getlist()
                })
            }
        }
        new lists()
    })
})